package org.feidao.chapter42.service.impl;

import org.feidao.chapter42.repository.HeroicRepository;
import org.feidao.chapter42.entity.Heroic;
import org.feidao.chapter42.service.HeroicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by linghufeixia on 2019-09-10.
 */
@Service
public class HeroicServiceImpl implements HeroicService {
    @Autowired
    private HeroicRepository heroicRepository;

    @Override
    public Heroic insertHeroic(Heroic heroic) {
        return heroicRepository.save(heroic);
    }

    @Override
    public void deleteHeroic(long id) {
         heroicRepository.deleteById(id);                ;
    }

    @Override
    public Heroic updateHeroic(Heroic heroic) {
        return heroicRepository.saveAndFlush(heroic);
    }

    @Override
    public List<Heroic> findList() {
        return heroicRepository.findAll();
    }
}
